package com.jin10.bean;


import com.jin10.enums.ResultCodeEnum;

public class BaseResponse {
    private static final String DEFAULT_SUCCESS_MESSAGE = null;
    private static final String DEFAULT_ERROR_MESSAGE = "error";


    private int status;
    private String message;
    private Object data;

    public BaseResponse() {

    }

    public BaseResponse(int status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public BaseResponse(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public BaseResponse(ResultCodeEnum resultCodeEnum) {
        this(resultCodeEnum.getStatus(), resultCodeEnum.getMessage());
    }

    public BaseResponse(ResultCodeEnum resultCodeEnum, Object data) {
        this(resultCodeEnum.getStatus(), resultCodeEnum.getMessage(), data);
    }

    public static BaseResponse ok() {
        return new BaseResponse(ResultCodeEnum.SUCCESS);
    }

    public static BaseResponse ok(Object data) {
        return new BaseResponse(ResultCodeEnum.SUCCESS, data);
    }


    public static BaseResponse error() {

        return new BaseResponse(ResultCodeEnum.DEFAULT_ERROR);
    }


    public static BaseResponse error(String message) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.status = ResultCodeEnum.DEFAULT_ERROR.getStatus();
        baseResponse.message = message;
        return baseResponse;
    }

    public static BaseResponse error(ResultCodeEnum resultCodeEnum) {
        return new BaseResponse(resultCodeEnum.getStatus(), resultCodeEnum.getMessage());
    }


    public static BaseResponse error(int errorCode, String message) {
        return new BaseResponse(errorCode, message);
    }


    public static BaseResponse error(Object data) {
        return new BaseResponse(ResultCodeEnum.DEFAULT_ERROR, data);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
